const { list, add, deleteRecord } = require('./data/movie-inner-test-data')

const base = '/movieserver'

module.exports = [{
  url: `${base}/innerTestMovies`,
  type: 'get',
  response: config => {
    const { page, limit, movieId, orgUnitId, roomId } = config.query
    return list(page, limit, movieId, orgUnitId, roomId)
  }
}, {
  url: `${base}/innerTestMovies`,
  type: 'post',
  response: config => {
    const { movieId, roomId } = config.body
    add({ movieId, roomId })
    return { success: true }
  }
}, {
  url: `${base}/innerTestMovies/[1-9][0-9]*`,
  type: 'delete',
  response: config => {
    const id = config.url.match(/[1-9][0-9]*/)
    deleteRecord(id)
    return { success: true }
  }
}]
